#include <stdio.h>
#include "base/abc/abc.h"
#include "base/main/main.h"
#include "aig/aig/aig.h"

typedef struct AppManager
{
    Abc_Ntk_t  * pNtk_app;           //近似过后的电路结构
    float        error_rate;         //设置错误率
    int          Id;                 //节点Id值    
    int          nNodes;             //节点数量
    int *        nCuts;
    void **      cut;
    int          MffcRootNode;       //记录Mffc的根节点
    int*         MffcNodes;          //记录根节点和它所包含的子节点
    int**        MffcArray;          //获取的Mffc根节点以及其所含子节点
    int*         MffcCone;           //子节点节点个数
}AppManager;




Abc_Ntk_t* NtktoAig(Abc_Ntk_t * pNtk);
Abc_Ntk_t* NtkStrash(Abc_Ntk_t * pNtk);
static Abc_Ntk_t *Ntk_Copy(Abc_Ntk_t *pNtk1);
Abc_Ntk_t* NtktoAig(Abc_Ntk_t * pNtk);
extern void AppManager_initial(AppManager *dMan, Abc_Ntk_t *pNtk);
void AppNodeMffcCone( Abc_Obj_t * pNode, AppManager *dMan);
void AppSaveMffc( Abc_Ntk_t * pNtk,  AppManager *dMan);
void AppReplaceMffc(Abc_Ntk_t * pNtk, Abc_Obj_t * pObj,AppManager *dMan,int module);
float  AppErrorcompute(Abc_Ntk_t* pNtk,Abc_Ntk_t* pNtk_app);
void   AppNtksplit(Abc_Ntk_t* pNtk, Abc_Obj_t * pNode, int fanoutnum,int module);
Abc_Obj_t * AppNtkCreateObj( Abc_Ntk_t * pNtk, Abc_ObjType_t Type );
void Apppreorder(Abc_Ntk_t*pNtk,Abc_Obj_t *pCopy,Abc_Obj_t* pNode);
int traceNodetoPo(Abc_Ntk_t * pNtk,Abc_Obj_t *pNode);
int GetAverageLevel(Abc_Ntk_t * pNtk, int level);
Abc_Ntk_t* GetBestNtk(Abc_Ntk_t * pNtk,Abc_Ntk_t * pNtk_org,double Lastrate,double bound,unsigned seed,int module,int errormodule);
double GetErrorRate(Abc_Ntk_t * pNtk_app,Abc_Ntk_t * pNtk_org);